package com.retrozelda.nyanimals;

import android.graphics.RectF;
import android.util.Log;

public class CStatusScreen extends INyanObject
{
	CRectangle m_Background;
	CRectangle m_HeaderText; // "Status Screen"
	
	CProgressBar m_AttackBar;
	CProgressBar m_RegenBar;
	CProgressBar m_DefenseBar;
	CProgressBar m_AffectionBar;
	
	CNyanimal					m_NyanimalToWatch;
	boolean						m_bVisible;
	
	public CStatusScreen()
	{

		m_Background = new CRectangle();
		m_HeaderText = new CRectangle();
		
		m_AttackBar = new CProgressBar();
		m_RegenBar = new CProgressBar();
		m_DefenseBar = new CProgressBar();
		m_AffectionBar = new CProgressBar();
		
		m_NyanimalToWatch = null;
		m_bVisible = false;
	}
	
	public void ToggleVisibility() { m_bVisible = !m_bVisible;}
	public boolean getVisibility() { return m_bVisible;}
	public void setVisibility(boolean bVisible) { m_bVisible = bVisible; }

	@Override
	public void Init(NyanimalGLSurfaceView game)
	{
		Log.d("CStatusScreen", "Dont use this init!");
	}

	public void Init(NyanimalGLSurfaceView game, CNyanimal nyanimal)
	{
		m_NyanimalToWatch = nyanimal;
		
		CTextureManager texMan = CTextureManager.GetInstance();
		CTexture bgTex = texMan.LoadTexture(R.drawable.statusscreen_bgcolor, game);
		CTexture headerTex = texMan.LoadTexture(R.drawable.status_screen_header, game);
		
		int nScreenMiddle = game.getWidth() / 2;
		
		m_Background.Init(game);
		m_Background.SetTexture(bgTex);
		m_Background.SetSize(game.getWidth(), game.getHeight());
		
		m_HeaderText.Init(game);
		m_HeaderText.SetTexture(headerTex);
		m_HeaderText.SetSize();
		m_HeaderText.SetPosition(nScreenMiddle, game.getHeight() / 6);
		m_HeaderText.Scale(0.5f, 0.5f);
		

		m_AttackBar.Init	(game, false, R.drawable.attack_frames,  	R.drawable.attack_gradient, nScreenMiddle - 256, 650, 256, 64, 100, 100);
		m_RegenBar.Init		(game, false, R.drawable.regen_frames, 	 	R.drawable.regen_gradient, nScreenMiddle - 256, 800, 256, 64, 100, 100);
		m_DefenseBar.Init	(game, false, R.drawable.defence_frames, 	R.drawable.defence_gradient, nScreenMiddle - 256, 950, 256, 64, 100, 100);
		m_AffectionBar.Init	(game, false, R.drawable.affection_frames,  R.drawable.affection_gradient, nScreenMiddle - 512, 1400, 512, 128, 100, 100);
		
		
		Log.d("CStatusScreen", "Init Progress bars");

	}

	@Override
	public void Update(float deltaTime) 
	{	
		
		m_Background.Update(deltaTime);
		m_HeaderText.Update(deltaTime);
		
		// set all the bars
		if(m_NyanimalToWatch != null)
		{
		}
		m_AttackBar.Update(deltaTime);
		m_RegenBar.Update(deltaTime);
		m_DefenseBar.Update(deltaTime);
		m_AffectionBar.Update(deltaTime);
		
	}

	@Override
	public void Draw(CArgumentGroup arg) 
	{
		if(m_bVisible == false)
		{
			return;
		}
		
		m_Background.Draw(arg);
		m_HeaderText.Draw(arg);
		m_AttackBar.Draw(arg);
		m_RegenBar.Draw(arg);
		m_DefenseBar.Draw(arg);
		m_AffectionBar.Draw(arg);
	}

	@Override
	public RectF CheckCollision(INyanObject inner)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void HandleCollision(INyanObject inner, RectF overlap) 
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean HandleTouch(int nPosX, int nPosY, int nTouchAction) 
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Type GetType()
	{
		// TODO Auto-generated method stub
		return null;
	}

}
